<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ include file="../session.jsp"%>
<!DOCTYPE html>
<html lang="ko">
  <head>
  	<%@ include file="../head.jsp"%>${alert}
  	<link rel="stylesheet" type="text/css" href="assets/css/lightbox.css" />
  </head>
  <body>
  	<%@ include file="../menu.jsp"%>
	<div class="container">
		<div class="page-header">
			<h2>회원 조회/수정</h2>
		</div>

		<form id="updateRegister" class="form-horizontal" role="form" method="post" action="updateRegister.do">
			<fieldset>
			
				<div class="form-group">
					<label for="isActivity" class="col-md-2 control-label">회원상태</label>
					<div class="col-md-10">
						<c:choose>
							<c:when test="${cmd.isActivity == 1}">
								<label class="radio-inline"><input type="radio" name="isActivity" value="1" checked> 사용중</label>
								<label class="radio-inline"><input type="radio" name="isActivity" value="0"> 미사용중</label>
							</c:when>
							<c:otherwise>
								<label class="radio-inline"><input type="radio" name="isActivity" value="1"> 사용중</label>
								<label class="radio-inline"><input type="radio" name="isActivity" value="0" checked> 미사용중</label>
							</c:otherwise>
						</c:choose>
					</div>
				</div>

				<div class="form-group">
					<label for="idRegister" class="col-md-2 control-label">회원번호</label>
					<div class="col-md-10">
						<input type="hidden" name="idRegister" value="${cmd.idRegister}"/>
						<p class="form-control-static">${cmd.idRegister}</p>
					</div>
				</div>

				<div class="form-group">
					<label for="nickName" class="col-md-2 control-label">닉네임</label>
					<div class="col-md-10">
						<p class="form-control-static">${cmd.nickName}</p>
					</div>
				</div>

				<div class="form-group">
					<label for="created_date" class="col-md-2 control-label">가입일</label>
					<div class="col-md-10">
						<p class="form-control-static">${fn:substring(cmd.create_date, 0, 4)}-${fn:substring(cmd.create_date, 4, 6)}-${fn:substring(cmd.create_date, 6, 8)}</p>
					</div>
				</div>

				<div class="form-group">
					<label for="userImg" class="col-md-2 control-label">사진</label>
					<div class="col-md-10">
						<c:choose>
							<c:when test="${image == null}">
								<p class="form-control-static">등록된 이미지가 존재하지 않습니다.</p>
							</c:when>
							<c:otherwise>
								<div class="row">
									<div class="col-md-3">
										<p class="form-control-static">
											<a href="download.jsp?${image}" data-lightbox="roadtrip" title="${cmd.nickName}">
												<img src="download.jsp?${image}" class="img-thumbnail img-responsive"/>
											</a>
										</p>
									</div>
									<div class="col-md-9">
										<br/>
										<ul>
											<li>항번: ${image.idAttacheFile}</li>
											<li>원본 파일 이름: ${image.fileOrgName}</li>
											<li>파일 크기: ${image.fileSize}byte</li>
											<li>업로드된 파일 이름: ${image.fileSaveName}</li>
											<li>업로드된 폴더 경로: ${image.fileDir}</li>
											<li>파일 타입: ${image.fileType}</li>
										</ul>
										&nbsp;&nbsp;&nbsp;&nbsp;
										<label class="checkbox-inline"><input type="checkbox" name="imgDelete" value="${image.fileSaveName}">
										(삭제) ${image.fileOrgName}</label>
									</div>
								</div>
							</c:otherwise>
						</c:choose>
					</div>
				</div>

				<div class="form-group">
					<label for="eMail" class="col-md-2 control-label">이메일</label>
					<div class="col-md-10">
						<p class="form-control-static">${cmd.eMail}</p>
					</div>
				</div>

				<div class="form-group">
					<label for="gender" class="col-md-2 control-label">성별</label>
					<div class="col-md-10">
						<p class="form-control-static">${cmd.genderValue}</p>
					</div>
				</div>

				<div class="form-group">
					<label for="birthYear" class="col-md-2 control-label">출생년도</label>
					<div class="col-md-10">
						<p class="form-control-static">${cmd.birthYear}년</p>
					</div>
				</div>

				<div class="form-group">
					<label for="skinType" class="col-md-2 control-label">피부타입</label>
					<div class="col-md-10">
						<p class="form-control-static">${cmd.skinTypeValue}</p>
					</div>
				</div>
				
				<div class="form-group">
					<label for="location" class="col-md-2 control-label">거주지역</label>
					<div class="col-md-10">
						<p class="form-control-static">${cmd.locationValue1}&nbsp;${cmd.locationValue2}</p>
					</div>
				</div>
				
				<div class="form-group">
					<label for="etc" class="col-md-2 control-label">기타정보</label>
					<div class="col-md-10">
						<div class="table-responsive">
							<table class="table table-condensed">
								<thead>
									<tr class="warning row">
										<th class="text-center col-md-3">파우치</th>
										<th class="text-center col-md-3">리뷰</th>
										<th class="text-center col-md-3">추천제품</th>
										<th class="text-center col-md-3">추천인</th>
									</tr>
								</thead>
								<tbody>
									<tr class="text-center row">
										<td class="col-md-3">
											<a href="listUserPouch.do?where= AND p.idRegister=${cmd.idRegister}"
												target="_blank">${cmd.pouchCount}</a>
										</td>
										<td class="col-md-3">
											<a href="reviewComment.do?where= AND c.idRegister=${cmd.idRegister}"
												target="_blank">${cmd.reviewCount}</a>
										</td>
										<td class="col-md-3">
											<a href="listProduct.do?where= AND p.idProduct in (SELECT idProduct FROM wishlistmapping WHERE idRegister=${cmd.idRegister})"
												target="_blank">${cmd.recommentCount}</a>
										</td>
										<td class="col-md-3">
											<a href="listRegister.do?where= AND recommender=${cmd.idRegister}"
												target="_blank">${cmd.wishCount}</a>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
				</div>

				<div class="form-group">
					<div class="col-md-offset-2 col-md-10">
						<div class="row">
							<div class="col-md-6">
								<button type="submit" id="updateConfirm" class="btn btn-primary btn-block">수정하기</button>
							</div>
							<div class="col-md-6">
								<button type="reset" class="btn btn-warning btn-block">다시작성</button>
							</div>
						</div>
					</div>
				</div>

			</fieldset>
		</form>
	</div>
	<!-- Javascript -->
	<script src="assets/js/jquery.js"></script>
	<script src="assets/js/bootstrap.min.js"></script>
	<script src="assets/js/lightbox-2.6.min.js"></script>
	<!-- 형식검사 클래스 참조 -->
	<script src="assets/js/string.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#updateRegister").submit(function() {
				
				if (!$("input[name='isActivity']").is(":checked")) {
					alert("회원상태를 선택해 주세요");
					$("input[name='isActivity']").focus();
					return false;
				}
				
				if (!confirm("정말 수정하시겠습니까?")) {
					return false;
				}
				
			});
		});
	</script>
	<script>
		$(function() {
			$("#delImg").click(function() {
				if (!confirm("정말 삭제하시겠습니까?")) {
					return false;
				}
			});
		});
	</script>
  </body>
</html>